﻿
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNet.Mvc;
using System.Net;
using System.IO;
using System.Text;
using System;


// For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860

namespace CardWarWEB.Controllers
{
    [Route("MainSpaceInfo")]
    public class MainSpaceInfoController : Controller
    {
        public IActionResult Index()
        {
            return View();
        }

        [Route("EvalCode")]
        public object EvalCode()
        {
            string skzy0 = Request.Query["skzy0"];
            if (string.IsNullOrEmpty(skzy0))
                return "Error";

            return View();
        }

        [Route("Coding")]
        [HttpPost]
        public object Coding(string skzy0, string code, string run) {
            if (string.IsNullOrEmpty(skzy0) || string.IsNullOrEmpty(code) || string.IsNullOrEmpty(run))
                return "Error";

            EvalResult evr = Server.Eval(code,run);
            if (evr.isSuccess)
                return evr.ReturnResult;
            else
                return evr.ErrorMessage;
        }

    }
}
